@use "sass:math";
@use "sass:meta";

@function strip-unit($value) {
  @if meta.type-of($value) == "number" and not math.is-unitless($value) {
    @return math.div($value, ($value * 0 + 1));
  }
  @return $value;
}

@mixin fluid-type($min-vw, $max-vw, $min-font-size, $max-font-size) {
  font-size: $min-font-size;

  @media screen and (min-width: $min-vw) {
    font-size: calc(
      #{$min-font-size} + #{strip-unit($max-font-size - $min-font-size)} *
        ((100vw - #{$min-vw}) / #{strip-unit($max-vw - $min-vw)})
    );
  }

  @media screen and (min-width: $max-vw) {
    font-size: $max-font-size;
  }
}
